Repository navigation
fix: refuse dsh native compaction with 422, not auth-class 403 (#2843) - #2844
ranxianglei merged 1 commit into
Conversation
[bot] 🏷 PR Review — #2844 (fixes #2843): dsh compaction refusal 403 → 422 Reviewed the full diff against current master ( ① Direction gate (原 issue) — #2843's end-to-end trace holds up: 403 is the credential-failure class for every client bili serves (dsh core ② Regression review (既有行为逐项) — audited every behavior on the touched paths:
高危域点名:自动更新/自更新路径 — untouched; dsh 相关功能 — this PR IS that domain, read line-by-line ✓;版本钉死/lockfile — untouched;systemd/env 模板 — untouched;网络/代理路径 — untouched. ③ Code review — core is a 2-line status change in both branches of
④ Test validity — the new regression test pins the class constraint (∉ {401,403} ∧ ∉ {408,409,429,≥500} ∧ stays 4xx) on all four lanes, which is better than pinning the literal value: it catches the bug family even if someone later swaps in another wrong status. Teeth verified by replaying it against master's guard file: fails with exactly ⑤ Diff cleanliness — one linear commit, 10 files, +40/−23, every line on-purpose; CONFIGURATION.md/.zh-CN.md regenerated from the yaml seed (I re-ran the generator: zero drift; Local verification (targeted only, per test discipline — full suite is CI's job): 结构化八问:
行为变更披露(旧值→新值):bili 本地产生的 dsh 压缩拒绝响应 HTTP 状态:403 → 422(全部线路 openai/anthropic/responses/google)。原因:#2843 的 AUTH 误分类链。wire-visible,故留人工审核层。 收工判定:代码与测试均可合;待最后 4 个全量 test 矩阵 CI job 转绿即可由人工合并。 |
[bot] 🏷 补充:head |
dshCompactionRefusal() answered 403 on every lane. 401/403 is the credential-failure class (HTTP semantics; Anthropic pairs 403 with permission_error, while the anthropic-lane refusal paired it with invalid_request_error), so clients that classify by status read a local policy refusal as a credential failure and may disable the credential. 422 keeps the refusal a non-retryable client error (not 408/409/429/5xx) without the auth semantics; body shapes are unchanged. Fixes #2843
0315c16 to
46f6e93
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.299-master.6fc3f9b # this exact build
npm install -g billion-context@master # always the newest merged build
|
Fixes #2843
What
dshCompactionRefusal()(src/server/dsh-compaction-guard.ts) now answers 422 instead of 403 on every lane (openai / anthropic / responses / google). Body shapes are unchanged (dsh_compaction_refused,retryable: false, same message). The two code comments and thedsh.allowDshCompaction/BILI_ALLOW_DSH_COMPACTIONdocs (en + zh, regenerated viatools/gen-config-docs.mjs) follow the new status.Why
The refusal is generated locally by bili. It is a policy decision about one request, but 403 tells the client something else:
permission_errorandinvalid_request_errorwith 400. The anthropic-lane refusal currently sends403+invalid_request_error, which is self-inconsistent.The guard's documented intent — a policy refusal that the caller must not retry as transient — only needs a non-retryable, non-auth client error.
Observed impact (details in #2843): dsh core maps
401 || 403toAUTH, and its GUI renders every AUTH failure asAPI 密钥无效/API key is invalid. With a third-party subscription-pool provider plugin that answers AUTH by cooling the account down for 24h, each refused compaction disabled the user's account, and every later turn failed until dsh was restarted. That plugin's classification is its own concern; this PR only stops bili from emitting an auth-class status for a non-auth refusal.Why 422 and not another status:
shouldRetryretries them, so the refused call would be replayedWire note: only the HTTP status of bili's own local refusal changes. No upstream request or response bytes are touched, and both compression modes are unaffected because the guard runs before any forwarding. This is still a wire-visible status change, so it belongs in the human-review tier.
Tests
tests/dsh-compaction-guard.test.ts: on every lane, the refusal status must be neither auth-class (401/403) nor transient-class (408/409/429/5xx). It fails on master (openai: 403 is auth-class) and passes here.tests/dsh-compaction-guard.test.ts,tests/issue2028-dsh-compaction-toggle.test.ts,tests/issue2490-ledger-floor-doomed-probe.test.ts, andtests/issue2709-passthrough-compaction-guard.test.ts.Pre-flight (Windows, node 24.16.0, on current master
cd02d2d)npm run typecheck✓dsh-compaction-guard,issue2028,issue2490,issue2658,issue2709-*): 46/46 ✓npm test: 6339 pass / 10 fail / 33 skipped. All 10 failures come from the local Windows environment (symlink EPERM, a stderr-pipe child timeout, DNS/socket behavior, host-detection tests picking up theDSH_*env of the shell I ran from, child exit3221226505). They fail the same way on unmodified master, and none of them touch the files in this PR. Linux CI is authoritative.npm run build✓node tools/gen-config-docs.mjs generatereports no drift;check-coverage✓;scripts/config-surface-guard.mjs✓Config surface
No config field is added or changed. The only change is the status code mentioned in the existing
dsh.allowDshCompaction/BILI_ALLOW_DSH_COMPACTIONdescriptions (403 → 422).